﻿# 20130606
# VMWare View 5.2
# This script creates a role for VMWare View Composer to operate in vCenter.
#
# Refer to the documentation
# http://pubs.vmware.com/view-52/index.jsp?topic=%2Fcom.vmware.view.installation.doc%2FGUID-A878F876-B359-42FC-9124-A1E34BFB3319.html&resultof=%22%41%63%74%22%20%22%61%63%74%22%20%22%76%63%65%6e%74%65%72%22%20%22%73%65%72%76%65%72%22%20

# Include any helper functions
. ".\include\*.ps1"

# Include any predefined variables
. ".\configuration.ps1"

# Name for our role
$myRole = "ViewComposerRole"

# Remove the role before trying to create it
removeRole($myRole)

# Create our role
new-virole -Name $myRole

# Privileges needed for the View Composer Role
$myGuestPrivileges = @("Allocate space", "Browse datastore", "Low level file operations", "Inventory", "Configuration", "State", "Clone virtual machine", "Allow disk access", "Assign virtual machine to resource pool", "Migrate powered off virtual machine", "Enable methods", "Disable methods", "System tag", "Network");

# Needed for View Storage Accelerator
$myStoragePrivileges = @("Act as vCenter Server")

# Set basic privs
set-virole -Role $myRole -AddPrivilege $myGuestPrivileges

# Set privs needed for storage accelerator
if ($boolStorageAccelerator) {
		set-virole -Role $myRole -AddPrivilege $myStoragePrivileges
}